﻿using UnityEngine;
using System.Collections;

public class BossBehavior : MonoBehaviour {
    GameObject player;
	Animator animator;
	[SerializeField] float minDis = 2.5f;
	// Use this for initialization
	void Start () {
		player = StaticVarFunc.Player;
		animator = GetComponentInChildren<Animator> ();
	}
	
	// Update is called once per frame
	void Update () {
		if (!animator.enabled)
			return;
		if (Vector3.Distance(player.transform.position, transform.position ) < minDis)
		{
			Vector3 target = player.transform.position;
			target.y = transform.position.y;
			transform.LookAt (target);
			animator.SetBool("Attack", true);
        }
        else
		{
			animator.SetBool("Attack", false);
        }
	}
}
